const { defineConfig } = require('@vue/cli-service');
const AutoImport = require('unplugin-auto-import/webpack');
const Components = require('unplugin-vue-components/webpack');
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers');

module.exports = defineConfig({
  transpileDependencies: true,
  lintOnSave: false,
  devServer: {
    historyApiFallback: true,
    port: 8081,
    proxy: {
      '/user': {
        target: 'http://localhost:8080', // 后端服务器地址
        changeOrigin: true
      },
      '/cart': {
        target: 'http://localhost:8080', // 后端服务器地址
        changeOrigin: true
      },
      '/products': {
        target: 'http://localhost:8080', // 后端服务器地址
        changeOrigin: true
      },
      '/uploads': {
        target: 'http://localhost:8080', // 后端服务器地址
        changeOrigin: true
      },
      '/order': {
        target: 'http://localhost:8080', // 后端服务器地址
        changeOrigin: true
      },
      '/shipping': {
        target: 'http://localhost:8080', // 后端服务器地址
        changeOrigin: true
      },
      '/payment': {
        target: 'http://localhost:8080',
        changeOrigin: true
      }
    }
  },
  configureWebpack: {
    plugins: [
      AutoImport({
        resolvers: [ElementPlusResolver()],
      }),
      Components({
        resolvers: [ElementPlusResolver()],
      }),
    ],
  },
});